Class HashSet<T>

A set collection class based on linear hashing

Implements

IEnumerable<T>, System.Collections.IEnumerable, System.IFormattable, System.ICloneable, ICollection<T>, ICollectionValue<T>, IExtensible<T>, IShowable

Bases

object, EnumerableBase<T>, CollectionValueBase<T>, CollectionBase<T>

Field overview

isReadOnly, Inherited from CollectionBase<T> ,
itemequalityComparer, Inherited from CollectionBase<T> ,
size, Inherited from CollectionBase<T> ,
stamp, Inherited from CollectionBase<T>

Event overview

CollectionChanged, Inherited from CollectionValueBase<T> ,
CollectionCleared, Inherited from CollectionValueBase<T> ,
ItemInserted, Inherited from CollectionValueBase<T> ,
ItemRemovedAt, Inherited from CollectionValueBase<T> ,
ItemsAdded, Inherited from CollectionValueBase<T> ,
ItemsRemoved, Inherited from CollectionValueBase<T>

Property overview

ActiveEvents, Inherited from CollectionValueBase<T> ,
AllowsDuplicates ,
ContainsSpeed ,
Count, Inherited from CollectionBase<T> ,
CountSpeed, Inherited from CollectionBase<T> ,
DuplicatesByCounting ,
EqualityComparer, Inherited from CollectionBase<T> ,
Features ,
IsEmpty, Inherited from CollectionBase<T> ,
IsReadOnly, Inherited from CollectionBase<T> ,
ListenableEvents ,
SyncRoot, Inherited from CollectionBase<T>

Constructor overview

HashSet<T>() ,
HashSet<T>(System.Collections.Generic.IEqualityComparer<T> itemequalityComparer) ,
HashSet<T>(int capacity, System.Collections.Generic.IEqualityComparer<T> itemequalityComparer) ,
HashSet<T>(int capacity, double fill, System.Collections.Generic.IEqualityComparer<T> itemequalityComparer)

Method overview

Add(T item) ,
AddAll<U>(IEnumerable<U> items) ,
All(Fun<T,bool> predicate), Inherited from CollectionValueBase<T> ,
Apply(Act<T> action), Inherited from CollectionValueBase<T> ,
BucketCostDistribution() ,
Check() ,
checkRange(int start, int count), Inherited from CollectionBase<T> ,
Choose() ,
Clear() ,
Clone() ,
Contains(T item) ,
ContainsAll<U>(IEnumerable<U> items) ,
ContainsCount(T item) ,
CopyTo(T[] array, int index), Inherited from CollectionValueBase<T> ,
Equals(object obj), Inherited from object ,
Exists(Fun<T,bool> predicate), Inherited from CollectionValueBase<T> ,
Filter(Fun<T,bool> predicate), Inherited from CollectionValueBase<T> ,
Finalize(), Inherited from object ,
Find(ref T item) ,
Find(Fun<T,bool> predicate, out T item), Inherited from CollectionValueBase<T> ,
FindOrAdd(ref T item) ,
GetEnumerator() ,
GetHashCode(), Inherited from object ,
GetType(), Inherited from object ,
GetUnsequencedHashCode(), Inherited from CollectionBase<T> ,
ItemMultiplicities() ,
MemberwiseClone(), Inherited from object ,
modifycheck(int thestamp), Inherited from CollectionBase<T> ,
raiseCollectionChanged(), Inherited from CollectionValueBase<T> ,
raiseCollectionCleared(bool full, int count), Inherited from CollectionValueBase<T> ,
raiseCollectionCleared(bool full, int count, System.Nullable<int> offset), Inherited from CollectionValueBase<T> ,
raiseForAdd(T item), Inherited from CollectionValueBase<T> ,
raiseForInsert(int i, T item), Inherited from CollectionValueBase<T> ,
raiseForRemove(T item), Inherited from CollectionValueBase<T> ,
raiseForRemove(T item, int count), Inherited from CollectionValueBase<T> ,
raiseForRemoveAll(ICollectionValue<T> wasRemoved), Inherited from CollectionValueBase<T> ,
raiseForRemoveAt(int index, T item), Inherited from CollectionValueBase<T> ,
raiseForSetThis(int index, T value, T item), Inherited from CollectionValueBase<T> ,
raiseForUpdate(T newitem, T olditem), Inherited from CollectionValueBase<T> ,
raiseForUpdate(T newitem, T olditem, int count), Inherited from CollectionValueBase<T> ,
raiseItemInserted(T item, int index), Inherited from CollectionValueBase<T> ,
raiseItemRemovedAt(T item, int index), Inherited from CollectionValueBase<T> ,
raiseItemsAdded(T item, int count), Inherited from CollectionValueBase<T> ,
raiseItemsRemoved(T item, int count), Inherited from CollectionValueBase<T> ,
Remove(T item) ,
Remove(T item, out T removeditem) ,
RemoveAll<U>(IEnumerable<U> items) ,
RemoveAllCopies(T item) ,
RetainAll<U>(IEnumerable<U> items) ,
Show(System.Text.StringBuilder stringbuilder, ref int rest, System.IFormatProvider formatProvider), Inherited from CollectionValueBase<T> ,
ToArray() ,
ToString(string format, System.IFormatProvider formatProvider), Inherited from CollectionValueBase<T> ,
ToString(), Inherited from CollectionValueBase<T> ,
UniqueItems() ,
UnsequencedEquals(ICollection<T> otherCollection), Inherited from CollectionBase<T> ,
Update(T item) ,
Update(T item, out T olditem) ,
updatecheck(), Inherited from CollectionBase<T> ,
UpdateOrAdd(T item) ,
UpdateOrAdd(T item, out T olditem)

Property details

bool AllowsDuplicatesAccess: Read-Only

Value:Always false

Report if this is a set collection.
Speed ContainsSpeedAccess: Read-Only

Value:Always returns Speed.Constant

The complexity of the Contains operation
bool DuplicatesByCountingAccess: Read-Only

Value:True if only one representative of a group of equal items is kept in the collection together with the total count.

By convention this is true for any collection with set semantics.
S HashSet<T>.Feature FeaturesAccess: Read-Only
Show which implementation features was chosen at compilation time
EventTypeEnum ListenableEventsAccess: Read-Only

Value:

Constructor details

HashSet<T>() Create a hash set with natural item equalityComparer and default fill threshold (66%) and initial table size (16).
HashSet<T>(System.Collections.Generic.IEqualityComparer<T> itemequalityComparer) Create a hash set with external item equalityComparer and default fill threshold (66%) and initial table size (16).
Parameters:
itemequalityComparer:The external item equalityComparer
HashSet<T>(int capacity, System.Collections.Generic.IEqualityComparer<T> itemequalityComparer) Create a hash set with external item equalityComparer and default fill threshold (66%)
Parameters:
capacity:Initial table size (rounded to power of 2, at least 16)
itemequalityComparer:The external item equalityComparer
HashSet<T>(int capacity, double fill, System.Collections.Generic.IEqualityComparer<T> itemequalityComparer) Create a hash set with external item equalityComparer.
Parameters:
capacity:Initial table size (rounded to power of 2, at least 16)
fill:Fill threshold (in range 10% to 90%)
itemequalityComparer:The external item equalityComparer

Method details

bool Add(T item) Add an item to this set.
Returns:True if item was added (i.e. not found)
Parameters:
item:The item to add.
void AddAll<U>(IEnumerable<U> items) Add the elements from another collection with a more specialized item type to this collection. Since this collection has set semantics, only items not already in the collection will be added.
Type parameters:
UThe type of items to add
Constraints:
U : T
Parameters:
items:The items to add
N ISortedDictionary<int,int> BucketCostDistribution() Produce statistics on distribution of bucket sizes. Current implementation is incomplete.
Returns:Histogram data.
bool Check() Test internal structure of data (invariants)
Returns:True if pass
T Choose() Choose some item of this collection.
Throws
NoSuchItemExceptionif collection is empty.
Returns:
void Clear() Remove all items from the set, resetting internal table to initial size.
object Clone() Make a shallow copy of this HashSet.
Returns:
bool Contains(T item) Check if an item is in the set
Returns:True if set contains item
Parameters:
item:The item to look for
bool ContainsAll<U>(IEnumerable<U> items) Check if all items in a supplied collection is in this set (ignoring multiplicities).
Type parameters:
U
Constraints:
U : T
Returns:True if all items are found.
Parameters:
items:The items to look for.
int ContainsCount(T item) Count the number of times an item is in this set (either 0 or 1).
Returns:1 if item is in set, 0 else
Parameters:
item:The item to look for.
bool Find(ref T item) Check if an item (collection equal to a given one) is in the set and if so report the actual item object found.
Returns:True if set contains item
Parameters:
item:On entry, the item to look for. On exit the item found, if any
bool FindOrAdd(ref T item) Check if an item (collection equal to a given one) is in the set. If found, report the actual item object in the set, else add the supplied one.
Returns:True if item was found
Parameters:
item:On entry, the item to look for or add. On exit the actual object found, if any.
System.Collections.Generic.IEnumerator<T> GetEnumerator() Create an enumerator for this set.
Returns:The enumerator
ICollectionValue<KeyValuePair<T,int>> ItemMultiplicities()
Returns:
bool Remove(T item) Remove an item from the set
Returns:True if item was (found and) removed
Parameters:
item:The item to remove
bool Remove(T item, out T removeditem) Remove an item from the set, reporting the actual matching item object.
Returns:True if item was found.
Parameters:
item:The value to remove.
removeditem:The removed value.
void RemoveAll<U>(IEnumerable<U> items) Remove all items in a supplied collection from this set.
Type parameters:
U
Constraints:
U : T
Parameters:
items:The items to remove.
void RemoveAllCopies(T item) Remove all (at most 1) copies of item from this set.
Parameters:
item:The item to remove
void RetainAll<U>(IEnumerable<U> items) Remove all items *not* in a supplied collection from this set.
Type parameters:
U
Constraints:
U : T
Parameters:
items:The items to retain
T[] ToArray() Create an array containing all items in this set (in enumeration order).
Returns:The array
ICollectionValue<T> UniqueItems()
Returns:
bool Update(T item) Check if an item (collection equal to a given one) is in the set and if so replace the item object in the set with the supplied one.
Returns:True if item was found (and updated)
Parameters:
item:The item object to update with
bool Update(T item, out T olditem) Check if an item (collection equal to a given one) is in the set and if so replace the item object in the set with the supplied one.
Returns:True if item was found (and updated)
Parameters:
item:The item object to update with
olditem:
bool UpdateOrAdd(T item) Check if an item (collection equal to a supplied one) is in the set and if so replace the item object in the set with the supplied one; else add the supplied one.
Returns:True if item was updated
Parameters:
item:The item to look for and update or add
bool UpdateOrAdd(T item, out T olditem) Check if an item (collection equal to a supplied one) is in the set and if so replace the item object in the set with the supplied one; else add the supplied one.
Returns:True if item was updated
Parameters:
item:The item to look for and update or add
olditem: